using System;
using System.Text;
using System.Reflection;
using System.Collections.Generic;



namespace Open.Data.Persistence
{
    public class Column: Expression, IColumn
    {
        //Properties
        public PropertyInfo PropertyInfo { get; set; }

        //Constructors
        internal protected Column(PropertyInfo property)
        {
            if (property == null) throw new ArgumentNullException();
            PropertyInfo = property;
        }

        internal protected Column(Type type, string property)
        {
            PropertyInfo = type.GetProperty(property);
            if (PropertyInfo == null) throw new Exception(string.Format("Property {0} not found for type {1}.", property, type.FullName));
        }

        //Methods
        public override IEnumerable<IParameter> GetParameters()
        {
            yield break;
        }

        public override void AppendHashCode(StringBuilder builder)
        {
            builder.Append(PropertyInfo.ToString());
        }
    }
}
